package demo2;

import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequencer;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {

    public void play() throws MidiUnavailableException {
        try {
            Sequencer sequencer= MidiSystem.getSequencer();
            System.out.println("Helloweenworld");
        } catch (MidiUnavailableException e) {
            e.printStackTrace();
        }
    }


    public static void main(String[] args) throws MidiUnavailableException {
        Test test = new Test();
        test.play();
    }



    public static void main3(String[] args) {
        int num1=10;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the number");
        int num2=sc.nextInt();
        //下面的这个代码就是对于我们的这个异常进行捕捉
        try{
            System.out.println("这个计算的结果就是我们的这个："+num1/num2);
        }catch(Exception e){
            e.printStackTrace();
        }
    }




    public static void main1(String[] args) {
        String str2="skjqjkuw[qweq]ewjkqj]eeieeeq[wieiwep[eeqweqewe]ewqewqe[eee[e[eee[[eeq]]qqelkkedkdk]qqklwlkekek";
        ArrayList<String> resultList = new ArrayList<>();
        int startIndex=0;
        while(true){
            int leftIndex=str2.indexOf('[',startIndex);
            if(leftIndex==-1){
                //这个时候表示没有找到
                break;
            }
            int rightIndex=str2.indexOf(']',leftIndex);
            if(rightIndex==-1){
                //这个表示没有找到括号
                break;
            }
            resultList.add(str2.substring(leftIndex+1,rightIndex));
            startIndex=rightIndex+1;
        }
        for(String result:resultList){
            System.out.println(result);
        }
    }
    public static void main2(String[] args) {
        String str2="skjqjkuw[qweq]ewjkqj]eeieeeq[wieiwep[eeqweqewe]ewqewqe[eee[e[eee[[eeq]]qqelkkedkdk]qqklwlkekek";
        List<String> resultList = new ArrayList<>();
        int startIndex = 0;
        while (true) {
            int leftBracketIndex = str2.indexOf('[', startIndex);
            if (leftBracketIndex == -1) {
                break;
            }
            int rightBracketIndex = str2.indexOf(']', leftBracketIndex);
            if (rightBracketIndex == -1) {
                break;
            }
            resultList.add(str2.substring(leftBracketIndex + 1, rightBracketIndex));
            startIndex = rightBracketIndex + 1;
        }
        for (String s : resultList) {
            System.out.println(s);
        }
    }
}
